package org.abc.fund.repository.trade;

import org.abc.fund.entity.trade.TradeOrder;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface TradeOrderRepository extends JpaRepository<TradeOrder, Long> {
  // 新增查询方法
  @Query("SELECT o FROM TradeOrder o WHERE o.status = 'FAILED' OR o.status = 'PARTIALLY_FAILED'")
  List<TradeOrder> findOrdersWithFailures();

  List<TradeOrder> findByStatus(TradeOrder.TradeStatus status);

  Page<TradeOrder> findByUser_Id(Long userId, Pageable pageable);

  Page<TradeOrder> findByUser_IdAndStatus(
      Long userId, TradeOrder.TradeStatus status, Pageable pageable);
}
